#include "any.h"
#include <unistd.h>
#include <string>
#include "buffer.h"
#include "socket.h"
#include "connection.h"
void MessageCallback( Connection* conn,Buffer* buffer){
    std::string data=buffer->ReadAndPop();
    std::cout<<"read callback:"<<data<<std::endl;
}
void ConnectedCallback( Connection* conn){
    std::cout<<"connect callback"<<std::endl;
    int fd=conn->Fd();
}
void CloseCallback( Connection* conn){
    std::cout<<"error callback"<<std::endl;
    int fd=conn->Fd();
    std::cout<<"fd:"<<fd<<std::endl;
}
void AnyEventCallback( Connection* conn){
    std::cout<<"event callback"<<std::endl;
    int fd=conn->Fd();
    std::cout<<"fd:"<<fd<<std::endl;
}
void eventcallback(){
    std::cout<<"有连接来了"<<std::endl;
}
int main(){
    TcpServer server(8080,0);
    server.SetConnectedCallback(ConnectedCallback);
    server.SetMessageCallback(MessageCallback);
    server.SetCloseCallback(CloseCallback);
    server.SetAnyEventCallback(AnyEventCallback);
    server.EnableInactiveRelease(15);
    server.Start();
    return 0;
}